package org.dawn.deveco.plugin.resourceeditor.model;

import org.dawn.deveco.plugin.resourceeditor.model.item.BaseItem;
import org.dawn.deveco.plugin.resourceeditor.model.item.SimpleItem;
import org.dawn.deveco.plugin.resourceeditor.utils.Logger;

import javax.swing.*;
import java.util.List;
import java.util.Vector;

public class ColorResourceContent extends SimpleResourceContent {
    private static final Logger LOG = Logger.getInstance(ColorResourceContent.class);

    public ColorResourceContent() {
        this("");
    }

    public ColorResourceContent(String category) {
        setCategory(category);
        setColumns(new ColumnConfig("Name", String.class, true, true),
                new ColumnConfig("Value", String.class, true, false, false, "颜色值通过选择器更改，不用手工编辑"),
                new ColumnConfig("", String.class, true, false, false, "选中颜色"),
                new ColumnConfig("", Icon.class, true, false, false, "删除按钮"));
    }

    public Vector<Vector> getJTableContent(String group) {
        List<? extends BaseItem> itemList = this.getGroupData(group);
        Vector<Vector> list = new Vector<>();
        for (final BaseItem e : itemList) {
            SimpleItem item = (SimpleItem) e;
            Vector<Object> vec = new Vector<>(3);
            vec.add(item.name);
            vec.add(item.value);
            vec.add(null);   // Color 列
            vec.add(null);   // Action 列
            list.add(vec);
        }
        return list;
    }
}
